import { ColorPicker } from 'antd';
import { useEffect, useState } from 'react';

export default function PickColor({ onChange, value }: any) {
  const [hex, setHex] = useState('');

  useEffect(() => {
    setHex(value);
  }, [value]);

  const handleChange = (e: any) => {
    onChange(`#${e.toHex()}`);
  };

  return <ColorPicker value={hex} onChange={handleChange} />;
}
